package com.congwulin.wechat.service;

import com.congwulin.wechat.entity.product.Product;
import com.congwulin.wechat.entity.product.ProductType;
import com.congwulin.wechat.mapper.product.ProductMapper;
import com.congwulin.wechat.mapper.product.ProductPersistent;
import com.congwulin.wechat.mapper.product.ProductTypeMapper;
import com.congwulin.wechat.mapper.product.ProductTypePersistent;
import com.congwulin.wechat.util.service.vo.VOPersistent;
import com.congwulin.wechat.util.service.vo.VOSaveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class ProductService {

    @Autowired
    private ProductMapper mapper;

    @Autowired
    private ProductTypeMapper typemapper;

    public List<Product> saveProduct(List<Product> list){
        VOPersistent voPersistent = new VOPersistent(new ProductPersistent(mapper));
        VOSaveService service = new VOSaveService(voPersistent);
        return (List<Product>)service.save(list);
    }

    public List<ProductType> saveProductType(List<ProductType> list){
        VOPersistent voPersistent = new VOPersistent(new ProductTypePersistent(typemapper));
        VOSaveService service = new VOSaveService(voPersistent);
        return (List<ProductType>)service.save(list);
    }

    public List<Product> selectProductByIDs(List<String> list){
        return mapper.selectByIDs(list);
    }

    public List<Product> selectProductByCodes(List<String> list){
        return mapper.selectByCodes(list);
    }

    public List<ProductType> selectProductTypeByIDs(List<String> list){
        return typemapper.selectByIDs(list);
    }
}
